<template>
<div>
  <ul>
    <li
      v-for="item in goodsList"
      :key="item.id"
      @click="toProductDetail(item.id)"
    >
      <van-image
        lazy-load
        :src="item.list_pic_url"
        style="display: block"
        width="100%"
        alt=""
      >
        <template v-slot:loading>
          <van-loading type="spinner" size="30" />
        </template>
      </van-image>
      <div class="van-ellipsis">{{ item.name }}</div>
      <div class="price">{{ item.retail_price | RMBformat }}</div>
    </li>
  </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {}
  },
  props: ["goodsList"],
  methods: {
    toProductDetail(id) {
      this.$router.push("/productDetail?id=" + id);
      setTimeout(() => {
        this.$router.go(0);
      }, 10)
    }
  }
}
</script>

<style lang="less" scoped>
ul {
  background: #efefef;
  padding: .4rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  li {
    width: 49%;
    margin-bottom: .5rem;
    background: #fff;
    text-align: center;
    line-height: 2.1rem;
    border-radius: .5rem;
    .van-ellipsis {
      padding: .7rem .5rem 0;
    }
    .price {
      color: darkred;
    }
  }
}
.loading{
  text-align: center;
  padding-bottom: .6rem;
}
.van-loading {
  display: block;
  background-color: #efefef;
}
</style>
